# Makefile for Python SLDT compiler
#
# Author:   Mike Murphy <mamurph@cs.clemson.edu>
# Revision: 11 January 2009
#
# NOTE: This Makefile uses non-standard targets. The targets are designed to
# comply with those specified in reference [1], page 34.
#
# [1]  Stevenson, D. E. "Programming Language Fundamentals by Example". Taylor
#      and Francis Group, 2007.
#

TESTFILES=final
JASMIN="jasmin-2.3/jasmin.jar"
JAVA="java"

stutest.out:
	chmod +x compiler_test
	./compiler_test tests/$(TESTFILES) all > stutest.out 2>&1
	cat stutest.out

proftest.out:
	echo "PROFTEST: $(PROFTEST)" > proftest.out
	echo "------------------- input -------------------" >> proftest.out
	cat $(PROFTEST) >> proftest.out
	echo "------------------- output -------------------" >> proftest.out
	rm -f ProfTest.class
	-python code_generator.py $(PROFTEST) ProfTest > ProfTest.j 2>> proftest.out
	-$(JAVA) -jar "$(JASMIN)" ProfTest.j >> proftest.out 2>&1
	-$(JAVA) ProfTest >> proftest.out 2>&1
	echo "----------------------------------------------" >> proftest.out
	cat proftest.out

clean:
	rm -f stutest.out proftest.out *.pyc ProfTest.j ProfTest.class

compiler:

# We actually WANT make to re-run stutest.out (and clobber the existing file)
# if the file exists, so declare the targets phony:
.PHONY: stutest.out proftest.out clean

